import React from 'react';
import { TreeSelect } from 'antd';
import { useDepartmentTree } from '../../hooks';

const SelectDepartment = ({ value, onChange, companyId = 101, ...restProps }, ref) => {
    const [loading, data = []] = useDepartmentTree(companyId);

    return (
        <TreeSelect
            ref={ref}
            loading={loading}
            treeData={data}
            value={value}
            onChange={onChange}
            style={{ width: 160 }}
            {...restProps}
        />
    );
};
export default React.forwardRef(SelectDepartment);
